package com.sa.estupendos.garena;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.sa.estupendos.garena.entity.User;
import com.sa.estupendos.garena.entity.dao.UserDAO;

public class GarenaBanMain {

	 public static final Log LOGGER = LogFactory.getLog(GarenaBanMain.class);
	/**
	 * @param args
	 */
 
	public static void main(String[] args) {
		
			ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");  
			UserDAO userDAO =(UserDAO) applicationContext.getBean("userDao");
			try {
		//		List<UserDAO> collection = userDAO.findAll();
				User test = userDAO.findByPK(4106002);
					System.out.println(test.getName());

					userDAO.remove(test);
				
			
			} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalStateException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}


			for (Iterator iterator = userDAO.findAll().iterator(); iterator.hasNext();) {
				User user = (User) iterator.next();
				LOGGER.info(user.getName());
				LOGGER.info(user.getId());
			} 

			
			

	}

}
